<?php
header('Content-Type:text/html;charset=utf-8');



?>
<html>
  <head>
    <title>点餐系统</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <script src="js/jquery-1.11.3.js"></script>
    <script src="js/bootstrap.js"></script>
  </head>
  <body>
    <?php include 'nav.php' ?>
    <div class="container">
      <div class="col-xs-2">
        <div class="list-group" style="margin-top:20px" align="center">
          <a href="#" class="list-group-item text-center" data-toggle="collapse" data-parent="#test1" data-target="#aaa" > 餐桌列表 </a>
          <a href="#" class="list-group-item text-center" data-toggle="collapse" data-parent="#test1" data-target="#bbb" > 添加餐桌 </a>
        </div>
      </div>
      <div class="col-xs-10">
        <div class="panel-group" id="test1">
          <div class="panel">
            <div class="panel panel-primary panel-collapse" id="aaa" style="margin-top:20px">
              <div class="panel-heading">
                <span class="glyphicon glyphicon-th-list"></span>
                餐桌列表 </div>
              <table class="table table-bordered">
                <tr>
                  <td>名称</td>
                </tr>
                <?php
                      $PDO=new PDO('mysql:dbname=diancan;charset=UTF8;','root');
                      $cz=$PDO->prepare('select * from canzhuo');
                      $cz->execute(array());
                      $AA=$cz->fetchAll(PDO::FETCH_NAMED);
                      foreach ($AA as $AB => $AC) 
                      {?>
                <tr>
                  <td><?php  
                        echo $AC['name'];
                        ?></td>
                  <td><div class="modal" id="modal<?php echo $AC['ID'] ?>">
                      <div class="modal-dialog" style="width:500px;">
                        <div class="modal-content">
                          <div class="modal-header" style="background-color:royalblue"> 删除确定<?php echo $AC['name'] ?>
                          </div>
                          <div class="modal-body"> 你确定要删除餐桌[<?php echo $AC['name']?>]吗？</div>
                          <div class="modal-footer">
                            <a href="/czsc.php?czid=<?php echo $AC['ID'] ?>" class="btn btn-primary">确认</a>
                            <a href="czgl.php" class="btn btn-default">取消</a>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="modal" id="mod<?php echo $AC['ID'] ?>">
                      <div class="modal-dialog" style="width:500px">
                        <div class="modal-content">
                          <form class="form-horizontal" method="post" action="xgcz.php">
                            <div class="modal-header">修改餐桌</div>
                            <div class="modal-body">
                              <div class="form-group">
                                <label class="control-label col-xs-3">原餐桌名：</label>
                                <div class="col-xs-8">
                                  <input  type="text" class="form-control" disabled="disabled" value="<?php echo $AC['name'] ?>">
                                </div>
                              </div>
                              <div class="form-group">
                                <label for="xgcz" class="control-label col-xs-3">新餐桌名:</label>
                                <div class="col-xs-8">
                                  <input type="hidden" name="id" value="<?php echo $AC['ID'] ?>" />
                                  <input id ="xgcz" type="text" class="form-control" name="xczm">
                                </div>
                              </div>
                            </div>
                            <div class="modal-footer">
                              <button type="submit" class="btn btn-primary">确定</button>
                              <a href="czgl.php" class="btn btn-default">取消</a>
                            </div>
                          </form>
                        </div>
                      </div>
                    </div>
                    <a class="btn btn-default" data-toggle="modal" data-target="#modal<?php echo $AC['ID'] ?>">删除</a>
                    <a class="btn btn-default" data-toggle="modal" data-target="#mod<?php echo $AC['ID'] ?>">修改</a></td>
                </tr>
                <?php
                      }
                    ?>
              </table>
            </div>         
          </div>

          <div class="panel col-xs-5">
            <div class="panel panel-primary panel-collapse collapse" id="bbb">
              <div class="panel-heading">添加餐桌</div>
              <form class="form-horizontal" method="post" action="tjcz.php">
                <div class="panel-body">
                  <label for="tjcz" class="col-xs-4">添加餐桌：</label>
                  <div class="col-xs-8">
                    <input  type="text" id="tjcz" name="tjcz">
                  </div>
                </div>
                <div class="panel-footer" align="right">
                  <button type="submit" class="btn btn-primary" >确定</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
        
      </div>
    </div>
  </body>
